import BaseEChart from "./BaseEChart";
import type { ECOption, IEChartValueType } from "../types";

interface PieEChartProps {
  pieData: IEChartValueType[];
}

const PieEChart: React.FC<PieEChartProps> = ({ pieData }) => {
  const option: ECOption = {
    tooltip: {
      trigger: "item",
    },
    legend: {
      top: "5%",
      left: "center",
    },
    series: [
      {
        name: "Access From",
        type: "pie",
        radius: ["40%", "70%"],
        avoidLabelOverlap: false,
        itemStyle: {
          borderRadius: 10,
          borderColor: "#fff",
          borderWidth: 2,
        },
        label: {
          show: false,
          position: "center",
        },
        emphasis: {
          label: {
            show: true,
            fontSize: 40,
            fontWeight: "bold",
          },
        },
        labelLine: {
          show: false,
        },
        data: pieData,
      },
    ],
  };
  return (
    <>
      <BaseEChart option={option} />
    </>
  );
};

export default PieEChart;
